import numpy as np
import torch.nn.functional as F
class Dropout(nn.Module):
    def __init__(self,dropout_rate,marray):
        super().__init__()
        self.dropout_rate=dropout_rate
        self.mask=nn.Parameter(m_array)
    def forward(self,input_x,train_if):
        if train_if:
            self.mask=np.random.rand(*input_x.shape)>self.dropout_rate
            return input_x * self.mask
        else:
            return input_x*(1-self.dropout_rate)
    def backward(self):
        pass